@ECHO OFF
rem #
rem # Copyright (c) 2016-2016 novunda
rem #

echo "                                                                         "
echo "         __    __  .______    __    __       _______. __    __           "
echo "        |  |  |  | |   _  \  |  |  |  |     /       ||  |  |  |          "
echo "        |  |__|  | |  |_)  | |  |  |  |    |   (---- |  |__|  |          "
echo "        |   __   | |   ___/  |  |  |  |     \   \    |   __   |          "
echo "        |  |  |  | |  |      |   --   | .----)   |   |  |  |  |          "
echo "        |__|  |__| | _|       \______/  |_______/    |__|  |__|          "
echo "                                                                         "
echo "                                                                         "

set "CURRENT_DIR=%cd%"
if not "%HPUSH_HOME%" == "" goto gotHome
set "HPUSH_HOME=%CURRENT_DIR%"
if exist "%HPUSH_HOME%\bin\hpush.bat" goto okHome
cd ..
set "HPUSH_HOME=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%HPUSH_HOME%\bin\hpush.bat" goto okHome
    echo The HPUSH_HOME environment variable is not defined correctly
    echo This environment variable is needed to run this program
goto end
:okHome

rem Set JavaHome if it exists
if exist { "%JAVA_HOME%\bin\java" } (
    set "JAVA="%JAVA_HOME%\bin\java""
)

echo Using JAVA_HOME:       "%JAVA_HOME%"
echo Using HPUSH_HOME:   "%HPUSH_HOME%"

rem  set LOG_CONSOLE_LEVEL=info
rem  set LOG_FILE_LEVEL=fine
set JAVA_OPTS=
set JAVA_OPTS_SCRIPT=-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true
set HPUSH_PATH=%HPUSH_HOME%
set LOG_FILE=%HPUSH_HOME%\config\hpush-log.properties
%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -DIGNITE_NO_ASCII=false -Dlog4j.configuration=file:%LOG_FILE% -Dhpush.path=%HPUSH_PATH% -cp %HPUSH_HOME%\lib\* com.novunda.hpush.server.HPushServer
pause